package com.qiye.pointsserver.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qiye.pointsserver.model.dto.AutherDto;
import com.qiye.pointsserver.model.dto.ProductDto;
import com.qiye.pointsserver.model.entity.Auther;
import com.qiye.pointsserver.model.entity.Product;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
* @author Lenovo
* @description 针对表【sys_product(产品积分表)】的数据库操作Mapper
* @createDate 2025-07-09 16:52:01
* @Entity com.qiye.pointsserver.model.entity.Product
*/
public interface ProductMapper extends BaseMapper<Product> {

    @Select("""
    SELECT 
     *
    FROM 
      sys_product as p
    WHERE
      (#{keyword} IS NULL OR #{keyword} = '' 
       OR p.name LIKE CONCAT('%', #{keyword}, '%') )
    ORDER BY p.create_time DESC
""")
    IPage<Product> searchPage(Page<?> page, @Param("keyword") String keyword);


    @Select("""
    SELECT 
     p.id,p.name,p.points,p.is_company,p.time
    FROM 
      sys_product as p
    ORDER BY p.create_time DESC
""")
    List<ProductDto> search();

}




